<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        /*  7.求1 + 2！ + 3！ + 4！....+20!的值
        - 2！ = 2 * 1
        - 3！ = 3 * 2 * 1 */
        
        var result = 0;  
        for (var i = 1; i <= 20; i++) {
            var t = 1;
            for (var n = 1; n <= i; n++) {
               t *= i;
            }
            result += t;
        }
        console.log(result);
        

        // 20! 的值。
        /* console.log(t);
        var t = 1;
        for (var i = 1; i <= 20; i++){
            t *= i;
        }
        console.log(t); */
    </script>
</body>

</html>